<?php

namespace app\validate;

use think\Validate;

class SystemDynamicFromField extends Validate
{

    protected $rule = [
        'name'=>['require'],
        'alias_field_id'=>['require'],
        'fid'=>['require'],
        'type'=>['require'],
        'require'=>['require'],

    ];

    protected $message = [
        'name.require'=>'字段名称为空',
        'alias_field_id.require'=>'字段别名为空',
        'fid.require'=>'关联模板id为空',
        'type.require'=>'字段类型为空',
        'type.integer'=>'字段类型值必须为int',
        'require.require'=>'是否必填为空',
        'require.integer'=>'是否必填必须为int',
        'is_k.require'=>'禁用启用标识为空',
        'is_k.integer'=>'禁用启用标识为空',

    ];

    //修改
    public function sceneEdit()
    {
        return $this->only([
            'id',
            'name',
            'alias_field_id',
            'fid',
            'type',
            'require'
        ])
            ->append('id','require');
    }

    //启用|禁用
    public function sceneEDField()
    {
        return $this->only([
            'id',
            'is_k'
        ])
            ->append('is_k','require|in:0,1')
            ->append('id','require');
    }
}